import sympy
import numpy as np
import matplotlib.pyplot as plt

# 定义变量
x = sympy.Symbol('x')
y = sympy.Symbol('y')
a = sympy.Symbol('a')
b = sympy.Symbol('b')
c = sympy.Symbol('c')

# 定义数学公式
# f = sympy.sin(x) ** 2 + sympy.cos(x) ** 2
f = x*x-20*x
# 转化为numpy函数以便于绘图
f_numpy = sympy.lambdify(x, f, 'numpy')

# 创建一个x值的数组
x_values = np.linspace(-10, 10, 1000)

# 计算y值
y_values = f_numpy(x_values)

# 绘制图形
plt.plot(x_values, y_values)
plt.show()
